import {
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  DeleteDateColumn,
  VersionColumn,
} from 'typeorm';

/**
 * 基础实体
 * 包含公共字段：ID、创建时间、更新时间、删除时间、是否删除、站点ID
 * 对应 Java: BaseEntity
 */
export abstract class BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @CreateDateColumn({
    name: 'create_time',
    type: 'timestamp',
    comment: '创建时间',
  })
  createTime: Date;

  @UpdateDateColumn({
    name: 'update_time',
    type: 'timestamp',
    comment: '更新时间',
  })
  updateTime: Date;

  @DeleteDateColumn({
    name: 'delete_time',
    type: 'timestamp',
    nullable: true,
    comment: '删除时间',
  })
  deleteTime: Date | null;

  @Column({
    name: 'is_delete',
    type: 'tinyint',
    default: 0,
    comment: '是否删除 0：否 1：是',
  })
  isDelete: number;

  @Column({
    name: 'site_id',
    type: 'int',
    default: 0,
    comment: '站点ID',
  })
  siteId: number;

  @VersionColumn({
    name: 'version',
    type: 'int',
    default: 1,
    comment: '版本号',
  })
  version: number;
}
